package com.seisys.controller.system.operationlog;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.seisys.controller.base.BaseController;
import com.seisys.service.system.LogService;
import com.seisys.util.Const;
import com.seisys.util.IData;
import com.seisys.util.IDataList;

/**
 * 类名称：AreaController 创建人：FH 创建时间：2017-04-07
 */
@Controller
@RequestMapping(value = "/log")
public class OperationLogController extends BaseController {

	@Resource(name = "logService")
	private LogService logService;

	/**
	 * 列表
	 */
	@SuppressWarnings({ "rawtypes" })
	@RequestMapping(value = "/list")
	@ResponseBody
	public Map<String, Object> list(int page, int size) {
		logBefore(logger, "操作日志列表");
		IData param = IData.getInstance(request);
		List list = IDataList.getInstance();
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			list = logService.logList(param);
		} catch (Exception e) {
			logger.error(e.toString(), e);
		}
		result.put("rows", list);
		result.put("total", param.getPage().getTotalResult());
		return result;
	}

	@RequestMapping(value = "/log_list")
	public ModelAndView log_list() {
		ModelAndView mv = this.getModelAndView();
		mv.setViewName("system/log/log_list");
		return mv;
	}

	public Map<String, String> getHC() {
		Subject currentUser = SecurityUtils.getSubject(); // shiro管理的session
		Session session = currentUser.getSession();
		return (Map<String, String>) session.getAttribute(Const.SESSION_QX);
	}
}
